home *** CD-ROM | disk | FTP | other *** search
- ; my includes
-
- include "exec/types.i"
- include "exec/execbase.i"
- include "libraries/dosextens.i"
- include "libraries/multireq.i"
- include "libraries/multireq_lib.i"
-
- ; some Functions not defined yet
-
- _ExecBase = 4
-
- _LVOOpenLibrary = -552
- _LVOCloseLibrary = -414
-
- _LVOWait = -318
- _LVOGetMsg = -372
- _LVOReplyMsg = -378
-
- _LVOOutput = -60
- _LVOOpen = -30
- _LVOClose = -36
- _LVODelay = -198
- _LVOWrite = -48
-
- ; the startup-code for WBStart
-
- _startup:
- move.l _ExecBase,a6
- move.l ThisTask(a6),a4 ;pointer to this task (better than FindTask !)
- move.l pr_CLI(a4),d0 ;has this task a CLI
- bne.s start_main ;program started from CLI
-
- ; Started from WorkBench
-
- lea pr_MsgPort(a4),a0
- moveq #1,d0
- moveq #0,d1
- move.b MP_SIGBIT(a0),d1
- asl.l d1,d0
- jsr _LVOWait(a6) ;Wait for a msg from WorkBench
-
- lea pr_MsgPort(a4),a0
- jsr _LVOGetMsg(a6) ;Get msg from WorkBench
- lea _WBMsg(pc),a0
- move.l d0,(a0)
-
- start_main:
- bsr.s _main
-
- move.l _WBMsg(pc),d0 ;is there a WorkBench msg ?
- beq.s go_home
-
- move.l d0,a1
- move.l _ExecBase,a6
- jsr _LVOReplyMsg(a6)
-
- go_home:
- moveq #0,d0
- rts
-
-
- _WBMsg: dc.l 0 ; Set if started from WorkBench
-
-
-
- ; the main program
-
- _main:
- move.l _ExecBase,a6
- lea DOSName(pc),a1
- moveq #0,d0
- jsr _LVOOpenLibrary(a6) ;Open dos.library
- lea _DOSBase(pc),a0
- move.l d0,(a0) ;get DOSBase
- beq _exit
-
- move.l _WBMsg(pc),d0 ; started from WBench ?
- bne.s out_win ; I was started from WBench
-
- move.l _DOSBase(pc),a6 ;DOSBase
- jsr _LVOOutput(a6) ;get output handle
- bra.s set_output
-
- out_win:
- move.l _DOSBase(pc),a6 ;DOSBase
- lea OutWin(pc),a0
- move.l a0,d1
- move.l #MODE_NEWFILE,d2
- jsr _LVOOpen(a6)
-
- set_output:
- lea _output(pc),a0
- move.l d0,(a0) ;save output handle
-
- move.l _ExecBase,a6
- lea MultiName(pc),a1
- moveq #0,d0
- jsr _LVOOpenLibrary(a6) ;Open multireq.library
- lea _MultiReqBase(pc),a0
- move.l d0,(a0) ;get MultiReqBase
- bne.s multi_ok
-
- move.l _DOSBase(pc),a6
- lea NoMultiReq(pc),a0
- move.l a0,d2 ;buffer
- move.l _output(pc),d1 ;handle
- moveq #30,d3 ;length
- jsr _LVOWrite(a6)
-
- bra.s no_multi
-
- multi_ok:
-
- ; Create a FileReq-structure
-
- move.l _MultiReqBase(pc),a6
- lea _fr(pc),a0 ;address of pointer to FileReq
- moveq #2,d0 ;this version only supports 2 filelists
- jsr _LVOInitFileReq(a6)
-
- move.l _fr(pc),d0 ;tst.l
- bne.s fr_ok
-
- move.l _DOSBase(pc),a6
- lea NoFileReq(pc),a0
- move.l a0,d2 ;buffer
- move.l _output(pc),d1 ;handle
- moveq #37,d3 ;length
- jsr _LVOWrite(a6)
-
- bra.s no_fr
-
- fr_ok: ;FileReq-structure ok
-
- ; Set some sample parameters
-
- bsr _SetParameters
-
- req_loop:
-
- ; start FileRequester on WorkBench-screen
-
- move.l _MultiReqBase(pc),a6
- move.l _fr(pc),a0 ;FileReq-structure
- sub.l a1,a1 ;use WorkBench-Screen
- jsr _LVOFileRequester(a6)
- move.w d0,d7 ;ReturnStatus
-
- ;Say how the FileRequester was ended
-
- bsr _WriteAction
-
- cmp.w #RET_OKAY,d7 ; should I start again ?
- beq.s req_loop
-
-
- ; Delete the FileReq-structure and free the memory */
-
- move.l _MultiReqBase(pc),a6
- lea _fr(pc),a0 ;address of pointer to FileReq
- jsr _LVOFreeFileReq(a6)
-
-
- no_fr: ; Close the multireq.library
- move.l _ExecBase,a6
- move.l _MultiReqBase(pc),a1
- jsr _LVOCloseLibrary(a6)
-
- no_multi: ; Close the dos.library
- move.l _WBMsg(pc),d0 ; started from WorkBench ?
- beq.s cl_multi ; I was started from CLI
-
- move.l _DOSBase(pc),a6
- moveq #100,d1
- jsr _LVODelay(a6) ;wait 2 seconds
-
- move.l _output(pc),d1
- jsr _LVOClose(a6)
-
- cl_multi:
- move.l _ExecBase,a6
- move.l _DOSBase(pc),a1
- jsr _LVOCloseLibrary(a6)
-
- _exit:
- rts ; everything done, bye !
-
-
-
- ; some important data
-
- _MultiReqBase: dc.l 0 ; a pointer to the multireq.library base
- _DOSBase: dc.l 0 ; a pointer to the dos.library base
- _fr: dc.l 0 ; memory for the pointer to the FileReq-structure
- _output: dc.l 0 ; output handle
-
- ; the name of the needed libraries
-
- DOSName: dc.b 'dos.library',0
- MultiName: dc.b 'multireq.library',0
-
- NoMultiReq: dc.b "Can't open multireq.library !",10
- NoFileReq: dc.b "Unable to create FileReq-structure !",10
-
- OutWin: dc.b "CON:0/14/400/100/SimpleDemo output window",0
-
- ; This routine is a example how to interpret the ReturnStatus of the
- ; FileRequester (notice the value ReturnStatus is identical to that returned
- ; by the FileRequester-function
-
-
- ; some texts
-
- Error: dc.b "Unable to open FileRequester !",10
- Cancel: dc.b "You've clicked on the Cancel-gadget",10
- Close: dc.b "You've clicked on the Close-gadget",10
- File: dc.b "You've pressed <RETURN> in the File-gadget",10
- Double: dc.b "You've done a DoubleClick on a File",10
- Okay: dc.b "You've pressed on the Okay-gadget",10
- dc.b " => the FileRequester is started again",10
- Sel: dc.b 10,"The follwing file was selected:"
- CR: dc.b 10,10
-
- EVEN
-
-
- _WriteAction:
- move.l _fr(pc),a0
- move.w fr_ReturnStatus(a0),d0
-
- cmp.w #RET_ERROR,d0 ; start successfull ?
- bne.s cancel_case
-
- lea Error(pc),a0 ;text
- moveq #31,d3 ;length
- bra.s wr_act
-
- cancel_case:
- cmp.w #RET_CANCEL,d0 ; Cancel-gadget pressed
- bne.s close_case
-
- lea Cancel(pc),a0 ;text
- moveq #36,d3 ;length
- bra.s wr_act
-
- close_case:
- cmp.w #RET_CLOSE,d0 ; Close-gadget pressed
- bne.s file_case
-
- lea Close(pc),a0 ;text
- moveq #35,d3 ;length
- bra.s wr_act
-
- file_case:
- cmp.w #RET_FILE,d0 ; RETURN pressed
- bne.s double_case
-
- lea File(pc),a0 ;text
- moveq #43,d3 ;length
- bra.s wr_act
-
- double_case:
- cmp.w #RET_DOUBLE,d0 ; DoubleClick on File
- bne.s okay_case
-
- lea Double(pc),a0 ;text
- moveq #36,d3 ;length
- bra.s wr_act
-
- okay_case:
- cmp.w #RET_OKAY,d0 ; Okay-gadget pressed
- bne.s wa_ret ; what status is this ?????
-
- lea Okay(pc),a0 ;text
- moveq #74,d3 ;length
-
- wr_act: ; Write done action
-
- move.l _DOSBase(pc),a6
- move.l _output(pc),d1 ;file handle
- move.l a0,d2 ;buffer
- jsr _LVOWrite(a6) ;d3 already set
-
- lea Sel(pc),a0
- move.l a0,d2 ;buffer
- move.l _output(pc),d1 ;file handle
- moveq #33,d3 ;length
- jsr _LVOWrite(a6)
-
- move.l _MultiReqBase(pc),a6
- move.l _fr(pc),a0
- move.l fr_FileNameBuff(a0),a0
- jsr _LVOStrLen(a6)
-
- move.l _DOSBase(pc),a6
- move.l d0,d3 ;length
- move.l _output(pc),d1 ;file handle
- move.l _fr(pc),a0
- move.l fr_FileNameBuff(a0),d2 ;buffer
- jsr _LVOWrite(a6)
-
- lea CR(pc),a0
- move.l a0,d2 ;buffer
- move.l _output(pc),d1 ;file handle
- moveq #2,d3 ;length
- jsr _LVOWrite(a6)
- wa_ret:
- rts
-
-
-
- ; the following part contains some parameters for the FileRequester
- ; all this parameters are optional, cause FileRequester also works, when no
- ; parameters are set (InitFileReq has done this for you)
-
-
- ; again some texts
-
- Title: dc.b "The multitasking FileRequester by Andreas Krebs",0
- OkayT: dc.b "go on",0
-
- Dir1: dc.b "SYS:",0
- Dir2: dc.b "DEVS:",0
- FileT: dc.b "SampleFile",0
- Show: dc.b "*.*|*-*",0 ; Show all files with a . or - in it
- Hide: dc.b "*+*",0 ; Hide all files with a + in it
-
- EVEN
-
- _SetParameters:
- move.l _fr(pc),a3
-
- lea Title(pc),a0
- move.l a0,fr_TitleString(a3) ;Set title of FileRequester
-
- lea OkayT(pc),a0
- move.l a0,fr_OkayString(a3) ;Set text of Okay-gadget
-
- move.w #20,fr_LeftEdge(a3) ;Set LeftEdge of FileRequester
- move.w #10,fr_TopEdge(a3) ;Set TopEdge of FileRequester
-
- move.b #1,fr_ActiveList(a3) ;Show filelist 2 first
- move.b #HIDE_INFO,fr_ShowInfo(a3) ;Don't show .info-files
-
- move.l _MultiReqBase(pc),a6
- lea FileT(pc),a0
- move.l fr_FileBuff(a3),a1
- jsr _LVOStrCpy(a6) ;File to be displayed in File-Gadget
-
- lea Show(pc),a0
- move.l fr_ShowBuff(a3),a1
- jsr _LVOStrCpy(a6) ;Files to be shown
-
- lea Hide(pc),a0
- move.l fr_HideBuff(a3),a1
- jsr _LVOStrCpy(a6) ;Files to be hidden
-
- lea Dir1(pc),a0
- move.l fr_FileList1+flt_DrawerBuff(a3),a1
- jsr _LVOStrCpy(a6) ;Set name of first directory
-
- move.w #NO_AUTOREAD,fr_FileList1+flt_AutoRead(a3)
- ; Do not automatically readin first directory
-
- lea Dir2(pc),a0
- move.l fr_FileList2+flt_DrawerBuff(a3),a1
- jsr _LVOStrCpy(a6) ;Set name of second directory
-
- move.w #DO_AUTOREAD,fr_FileList2+flt_AutoRead(a3)
- ; Do automatically readin second directory
-
- rts
-
-
- END
-